package com.jishaokang.service.impl;

import com.jishaokang.base.Result;
import com.jishaokang.cache.ResultCache;
import com.jishaokang.dao.ConstDAO;
import com.jishaokang.model.dto.Const;
import com.jishaokang.model.dto.Course;
import com.jishaokang.service.ConstService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by NANA_Final on 2019/6/21.
 */
@Service
public class ConstServiceImpl implements ConstService {

    @Autowired
    private ConstDAO constDAO;

    @Override
    public Result selectMaskWord() {
        Const const1 =constDAO.select("maskWord");
        constDAO.update(const1);
        return ResultCache.getDataOk(const1.getConstValue());
    }

    @Override
    public Result updateMaskWord(Const maskWord) {
        Const const1 = new Const();
        const1.setConstType("maskWord");
        const1.setConstValue(maskWord.getMaskWord());
        constDAO.update(const1);
        return ResultCache.OK;
    }

    @Override
    public Result selectLabel() {
        Const const1 =constDAO.select("label");
        constDAO.update(const1);
        return ResultCache.getDataOk(const1);
    }

    @Override
    public Result updateLabel(String label) {
        Const const1 = new Const();
        const1.setConstType("label");
        const1.setConstValue(label);
        constDAO.update(const1);
        return ResultCache.OK;
    }
}